home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat3 / Tk / photo.z / photo
Text File  |  1998-10-30  |  23KB  |  463 lines

  1.  
  2.  
  3.  
  4. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      photo - Full-color images
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      iiiimmmmaaaaggggeeee ccccrrrreeeeaaaatttteeee pppphhhhoooottttoooo ?_n_a_m_e? ?_o_p_t_i_o_n_s?
  13.  
  14.  
  15. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.      A photo is an image whose pixels can display any color or be transparent.
  17.      A photo image is stored internally in full color (24 bits per pixel), and
  18.      is displayed using dithering if necessary.  Image data for a photo image
  19.      can be obtained from a file or a string, or it can be supplied from C
  20.      code through a procedural interface.  At present, only GIF and PPM/PGM
  21.      formats are supported, but an interface exists to allow additional image
  22.      file formats to be added easily.  A photo image is transparent in regions
  23.      where no image data has been supplied.
  24.  
  25.  
  26. CCCCRRRREEEEAAAATTTTIIIINNNNGGGG PPPPHHHHOOOOTTTTOOOOSSSS
  27.      Like all images, photos are created using the iiiimmmmaaaaggggeeee ccccrrrreeeeaaaatttteeee command.
  28.      Photos support the following _o_p_t_i_o_n_s:
  29.  
  30.      ----ddddaaaattttaaaa _s_t_r_i_n_g
  31.           Specifies the contents of the image as a string.  The format of the
  32.           string must be one of those for which there is an image file format
  33.           handler that will accept string data.  If both the ----ddddaaaattttaaaa and ----ffffiiiilllleeee
  34.           options are specified, the ----ffffiiiilllleeee option takes precedence.
  35.  
  36.      ----ffffoooorrrrmmmmaaaatttt _f_o_r_m_a_t-_n_a_m_e
  37.           Specifies the name of the file format for the data specified with
  38.           the ----ddddaaaattttaaaa or ----ffffiiiilllleeee option.
  39.  
  40.      ----ffffiiiilllleeee _n_a_m_e
  41.           _n_a_m_e gives the name of a file that is to be read to supply data for
  42.           the photo image.  The file format must be one of those for which
  43.           there is an image file format handler that can read data from a
  44.           file.
  45.  
  46.      ----ggggaaaammmmmmmmaaaa _v_a_l_u_e
  47.           Specifies that the colors allocated for displaying this image in a
  48.           window should be corrected for a non-linear display with the
  49.           specified gamma exponent value.  (The intensity produced by most CRT
  50.           displays is a power function of the input value, to a good
  51.           approximation; gamma is the exponent and is typically around 2).
  52.           The value specified must be greater than zero.  The default value is
  53.           one (no correction).  In general, values greater than one will make
  54.           the image lighter, and values less than one will make it darker.
  55.  
  56.      ----hhhheeeeiiiigggghhhhtttt _n_u_m_b_e_r
  57.           Specifies the height of the image, in pixels.  This option is useful
  58.           primarily in situations where the user wishes to build up the
  59.           contents of the image piece by piece.  A value of zero (the default)
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  71.  
  72.  
  73.  
  74.           allows the image to expand or shrink vertically to fit the data
  75.           stored in it.
  76.  
  77.      ----ppppaaaalllleeeetttttttteeee _p_a_l_e_t_t_e-_s_p_e_c
  78.           Specifies the resolution of the color cube to be allocated for
  79.           displaying this image, and thus the number of colors used from the
  80.           colormaps of the windows where it is displayed.  The _p_a_l_e_t_t_e-_s_p_e_c
  81.           string may be either a single decimal number, specifying the number
  82.           of shades of gray to use, or three decimal numbers separated by
  83.           slashes (/), specifying the number of shades of red, green and blue
  84.           to use, respectively.  If the first form (a single number) is used,
  85.           the image will be displayed in monochrome (i.e., grayscale).
  86.  
  87.      ----wwwwiiiiddddtttthhhh _n_u_m_b_e_r
  88.           Specifies the width of the image, in pixels.    This option is
  89.           useful primarily in situations where the user wishes to build up the
  90.           contents of the image piece by piece.  A value of zero (the default)
  91.           allows the image to expand or shrink horizontally to fit the data
  92.           stored in it.
  93.  
  94.  
  95. IIIIMMMMAAAAGGGGEEEE CCCCOOOOMMMMMMMMAAAANNNNDDDD
  96.      When a photo image is created, Tk also creates a new command whose name
  97.      is the same as the image.  This command may be used to invoke various
  98.      operations on the image.  It has the following general form:
  99.  
  100.           _i_m_a_g_e_N_a_m_e _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
  101.  
  102.      _O_p_t_i_o_n and the _a_r_gs determine the exact behavior of the command.
  103.  
  104.      Those options that write data to the image generally expand the size of
  105.      the image, if necessary, to accommodate the data written to the image,
  106.      unless the user has specified non-zero values for the ----wwwwiiiiddddtttthhhh and/or
  107.      ----hhhheeeeiiiigggghhhhtttt configuration options, in which case the width and/or height,
  108.      respectively, of the image will not be changed.
  109.  
  110.      The following commands are possible for photo images:
  111.  
  112.      _i_m_a_g_e_N_a_m_e bbbbllllaaaannnnkkkk
  113.           Blank the image; that is, set the entire image to have no data, so
  114.           it will be displayed as transparent, and the background of whatever
  115.           window it is displayed in will show through.
  116.  
  117.      _i_m_a_g_e_N_a_m_e ccccggggeeeetttt _o_p_t_i_o_n
  118.           Returns the current value of the configuration option given by
  119.           _o_p_t_i_o_n.  _O_p_t_i_o_n may have any of the values accepted by the iiiimmmmaaaaggggeeee
  120.           ccccrrrreeeeaaaatttteeee pppphhhhoooottttoooo command.
  121.  
  122.      _i_m_a_g_e_N_a_m_e ccccoooonnnnffffiiiigggguuuurrrreeee ?_o_p_t_i_o_n? ?_v_a_l_u_e _o_p_t_i_o_n _v_a_l_u_e ...?
  123.           Query or modify the configuration options for the image.  If no
  124.           _o_p_t_i_o_n is specified, returns a list describing all of the available
  125.           options for _i_m_a_g_e_N_a_m_e (see TTTTkkkk____CCCCoooonnnnffffiiiigggguuuurrrreeeeIIIInnnnffffoooo for information on the
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  137.  
  138.  
  139.  
  140.           format of this list).  If _o_p_t_i_o_n is specified with no _v_a_l_u_e, then
  141.           the command returns a list describing the one named option (this
  142.           list will be identical to the corresponding sublist of the value
  143.           returned if no _o_p_t_i_o_n is specified).  If one or more _o_p_t_i_o_n-_v_a_l_u_e
  144.           pairs are specified, then the command modifies the given option(s)
  145.           to have the given value(s);  in this case the command returns an
  146.           empty string.  _O_p_t_i_o_n may have any of the values accepted by the
  147.           iiiimmmmaaaaggggeeee ccccrrrreeeeaaaatttteeee pppphhhhoooottttoooo command.
  148.  
  149.      _i_m_a_g_e_N_a_m_e ccccooooppppyyyy _s_o_u_r_c_e_I_m_a_g_e ?_o_p_t_i_o_n _v_a_l_u_e(_s) ...?
  150.           Copies a region from the image called _s_o_u_r_c_e_I_m_a_g_e (which must be a
  151.           photo image) to the image called _i_m_a_g_e_N_a_m_e, possibly with pixel
  152.           zooming and/or subsampling.  If no options are specified, this
  153.           command copies the whole of _s_o_u_r_c_e_I_m_a_g_e into _i_m_a_g_e_N_a_m_e, starting at
  154.           coordinates (0,0) in _i_m_a_g_e_N_a_m_e.  The following options may be
  155.           specified:
  156.  
  157.           ----ffffrrrroooommmm _x_1 _y_1 _x_2 _y_2
  158.                Specifies a rectangular sub-region of the source image to be
  159.                copied.  (_x_1,_y_1) and (_x_2,_y_2) specify diagonally opposite
  160.                corners of the rectangle.  If _x_2 and _y_2 are not specified, the
  161.                default value is the bottom-right corner of the source image.
  162.                The pixels copied will include the left and top edges of the
  163.                specified rectangle but not the bottom or right edges.  If the
  164.                ----ffffrrrroooommmm option is not given, the default is the whole source
  165.                image.
  166.  
  167.           ----ttttoooo _x_1 _y_1 _x_2 _y_2
  168.                Specifies a rectangular sub-region of the destination image to
  169.                be affected.  (_x_1,_y_1) and (_x_2,_y_2) specify diagonally opposite
  170.                corners of the rectangle.  If _x_2 and _y_2 are not specified, the
  171.                default value is (_x_1,_y_1) plus the size of the source region
  172.                (after subsampling and zooming, if specified).  If _x_2 and _y_2
  173.                are specified, the source region will be replicated if
  174.                necessary to fill the destination region in a tiled fashion.
  175.  
  176.           ----sssshhhhrrrriiiinnnnkkkk
  177.                Specifies that the size of the destination image should be
  178.                reduced, if necessary, so that the region being copied into is
  179.                at the bottom-right corner of the image.  This option will not
  180.                affect the width or height of the image if the user has
  181.                specified a non-zero value for the ----wwwwiiiiddddtttthhhh or ----hhhheeeeiiiigggghhhhtttt
  182.                configuration option, respectively.
  183.  
  184.           ----zzzzoooooooommmm _x _y
  185.                Specifies that the source region should be magnified by a
  186.                factor of _x in the X direction and _y in the Y direction.  If _y
  187.                is not given, the default value is the same as _x.  With this
  188.                option, each pixel in the source image will be expanded into a
  189.                block of _x x _y pixels in the destination image, all the same
  190.                color.  _x and _y must be greater than 0.
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  203.  
  204.  
  205.  
  206.           ----ssssuuuubbbbssssaaaammmmpppplllleeee _x _y
  207.                Specifies that the source image should be reduced in size by
  208.                using only every _xth pixel in the X direction and _yth pixel in
  209.                the Y direction.  Negative values will cause the image to be
  210.                flipped about the Y or X axes, respectively.  If _y is not
  211.                given, the default value is the same as _x.
  212.  
  213.      _i_m_a_g_e_N_a_m_e ggggeeeetttt _x _y
  214.           Returns the color of the pixel at coordinates (_x,_y) in the image as
  215.           a list of three integers between 0 and 255, representing the red,
  216.           green and blue components respectively.
  217.  
  218.      _i_m_a_g_e_N_a_m_e ppppuuuutttt _d_a_t_a ?----ttttoooo _x_1 _y_1 _x_2 _y_2?
  219.           Sets pixels in _i_m_a_g_e_N_a_m_e to the colors specified in _d_a_t_a.  _d_a_t_a is
  220.           used to form a two-dimensional array of pixels that are then copied
  221.           into the _i_m_a_g_e_N_a_m_e.  _d_a_t_a is structured as a list of horizontal
  222.           rows, from top to bottom, each of which is a list of colors, listed
  223.           from left to right.  Each color may be specified by name (e.g.,
  224.           blue) or in hexadecimal form (e.g., #2376af).  The ----ttttoooo option can be
  225.           used to specify the area of _i_m_a_g_e_N_a_m_e to be affected.  If only _x_1
  226.           and _y_1 are given, the area affected has its top-left corner at
  227.           (_x_1,_y_1) and is the same size as the array given in _d_a_t_a.  If all
  228.           four coordinates are given, they specify diagonally opposite corners
  229.           of the affected rectangle, and the array given in _d_a_t_a will be
  230.           replicated as necessary in the X and Y directions to fill the
  231.           rectangle.
  232.  
  233.      _i_m_a_g_e_N_a_m_e rrrreeeeaaaadddd _f_i_l_e_n_a_m_e ?_o_p_t_i_o_n _v_a_l_u_e(_s) ...?
  234.           Reads image data from the file named _f_i_l_e_n_a_m_e into the image.  This
  235.           command first searches the list of image file format handlers for a
  236.           handler that can interpret the data in _f_i_l_e_n_a_m_e, and then reads the
  237.           image in _f_i_l_e_n_a_m_e into _i_m_a_g_e_N_a_m_e (the destination image).  The
  238.           following options may be specified:
  239.  
  240.           ----ffffoooorrrrmmmmaaaatttt _f_o_r_m_a_t-_n_a_m_e
  241.                Specifies the format of the image data in _f_i_l_e_n_a_m_e.
  242.                Specifically, only image file format handlers whose names begin
  243.                with _f_o_r_m_a_t-_n_a_m_e will be used while searching for an image data
  244.                format handler to read the data.
  245.  
  246.           ----ffffrrrroooommmm _x_1 _y_1 _x_2 _y_2
  247.                Specifies a rectangular sub-region of the image file data to be
  248.                copied to the destination image.  If only _x_1 and _y_1 are
  249.                specified, the region extends from (_x_1,_y_1) to the bottom-right
  250.                corner of the image in the image file.  If all four coordinates
  251.                are specified, they specify diagonally opposite corners or the
  252.                region.  The default, if this option is not specified, is the
  253.                whole of the image in the image file.
  254.  
  255.           ----sssshhhhrrrriiiinnnnkkkk
  256.                If this option, the size of _i_m_a_g_e_N_a_m_e will be reduced, if
  257.                necessary, so that the region into which the image file data
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  269.  
  270.  
  271.  
  272.                are read is at the bottom-right corner of the _i_m_a_g_e_N_a_m_e.  This
  273.                option will not affect the width or height of the image if the
  274.                user has specified a non-zero value for the ----wwwwiiiiddddtttthhhh or ----hhhheeeeiiiigggghhhhtttt
  275.                configuration option, respectively.
  276.  
  277.           ----ttttoooo _x _y
  278.                Specifies the coordinates of the top-left corner of the region
  279.                of _i_m_a_g_e_N_a_m_e into which data from _f_i_l_e_n_a_m_e are to be read.  The
  280.                default is (0,0).
  281.  
  282.      _i_m_a_g_e_N_a_m_e rrrreeeeddddiiiitttthhhheeeerrrr
  283.           The dithering algorithm used in displaying photo images propagates
  284.           quantization errors from one pixel to its neighbors.  If the image
  285.           data for _i_m_a_g_e_N_a_m_e is supplied in pieces, the dithered image may not
  286.           be exactly correct.  Normally the difference is not noticeable, but
  287.           if it is a problem, this command can be used to recalculate the
  288.           dithered image in each window where the image is displayed.
  289.  
  290.      _i_m_a_g_e_N_a_m_e wwwwrrrriiiitttteeee _f_i_l_e_n_a_m_e ?_o_p_t_i_o_n _v_a_l_u_e(_s) ...?
  291.           Writes image data from _i_m_a_g_e_N_a_m_e to a file named _f_i_l_e_n_a_m_e.  The
  292.           following options may be specified:
  293.  
  294.           ----ffffoooorrrrmmmmaaaatttt _f_o_r_m_a_t-_n_a_m_e
  295.                Specifies the name of the image file format handler to be used
  296.                to write the data to the file.  Specifically, this subcommand
  297.                searches for the first handler whose name matches a initial
  298.                substring of _f_o_r_m_a_t-_n_a_m_e and which has the capability to write
  299.                an image file.  If this option is not given, this subcommand
  300.                uses the first handler that has the capability to write an
  301.                image file.
  302.  
  303.           ----ffffrrrroooommmm _x_1 _y_1 _x_2 _y_2
  304.                Specifies a rectangular region of _i_m_a_g_e_N_a_m_e to be written to
  305.                the image file.  If only _x_1 and _y_1 are specified, the region
  306.                extends from (_x_1,_y_1) to the bottom-right corner of _i_m_a_g_e_N_a_m_e.
  307.                If all four coordinates are given, they specify diagonally
  308.                opposite corners of the rectangular region.  The default, if
  309.                this option is not given, is the whole image.
  310.  
  311. IIIIMMMMAAAAGGGGEEEE FFFFOOOORRRRMMMMAAAATTTTSSSS
  312.      The photo image code is structured to allow handlers for additional image
  313.      file formats to be added easily.  The photo image code maintains a list
  314.      of these handlers.  Handlers are added to the list by registering them
  315.      with a call to TTTTkkkk____CCCCrrrreeeeaaaatttteeeePPPPhhhhoooottttooooIIIImmmmaaaaggggeeeeFFFFoooorrrrmmmmaaaatttt.  The standard Tk distribution
  316.      comes with handlers for PPM/PGM and GIF formats, which are automatically
  317.      registered on initialization.
  318.  
  319.      When reading an image file or processing string data specified with the
  320.      ----ddddaaaattttaaaa configuration option, the photo image code invokes each handler in
  321.      turn until one is found that claims to be able to read the data in the
  322.      file or string.  Usually this will find the correct handler, but if it
  323.      doesn't, the user may give a format name with the ----ffffoooorrrrmmmmaaaatttt option to
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  335.  
  336.  
  337.  
  338.      specify which handler to use.  In fact the photo image code will try
  339.      those handlers whose names begin with the string specified for the
  340.      ----ffffoooorrrrmmmmaaaatttt option (the comparison is case-insensitive).  For example, if the
  341.      user specifies ----ffffoooorrrrmmmmaaaatttt ggggiiiiffff, then a handler named GIF87 or GIF89 may be
  342.      invoked, but a handler named JPEG may not (assuming that such handlers
  343.      had been registered).
  344.  
  345.      When writing image data to a file, the processing of the ----ffffoooorrrrmmmmaaaatttt option
  346.      is slightly different: the string value given for the ----ffffoooorrrrmmmmaaaatttt option must
  347.      begin with the complete name of the requested handler, and may contain
  348.      additional information following that, which the handler can use, for
  349.      example, to specify which variant to use of the formats supported by the
  350.      handler.
  351.  
  352.  
  353. CCCCOOOOLLLLOOOORRRR AAAALLLLLLLLOOOOCCCCAAAATTTTIIIIOOOONNNN
  354.      When a photo image is displayed in a window, the photo image code
  355.      allocates colors to use to display the image and dithers the image, if
  356.      necessary, to display a reasonable approximation to the image using the
  357.      colors that are available.  The colors are allocated as a color cube,
  358.      that is, the number of colors allocated is the product of the number of
  359.      shades of red, green and blue.
  360.  
  361.      Normally, the number of colors allocated is chosen based on the depth of
  362.      the window.  For example, in an 8-bit PseudoColor window, the photo image
  363.      code will attempt to allocate seven shades of red, seven shades of green
  364.      and four shades of blue, for a total of 198 colors.  In a 1-bit
  365.      StaticGray (monochrome) window, it will allocate two colors, black and
  366.      white.  In a 24-bit DirectColor or TrueColor window, it will allocate 256
  367.      shades each of red, green and blue.  Fortunately, because of the way that
  368.      pixel values can be combined in DirectColor and TrueColor windows, this
  369.      only requires 256 colors to be allocated.  If not all of the colors can
  370.      be allocated, the photo image code reduces the number of shades of each
  371.      primary color and tries again.
  372.  
  373.      The user can exercise some control over the number of colors that a photo
  374.      image uses with the ----ppppaaaalllleeeetttttttteeee configuration option.  If this option is
  375.      used, it specifies the maximum number of shades of each primary color to
  376.      try to allocate.  It can also be used to force the image to be displayed
  377.      in shades of gray, even on a color display, by giving a single number
  378.      rather than three numbers separated by slashes.
  379.  
  380.  
  381. CCCCRRRREEEEDDDDIIIITTTTSSSS
  382.      The photo image type was designed and implemented by Paul Mackerras,
  383.      based on his earlier photo widget and some suggestions from John
  384.      Ousterhout.
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. pppphhhhoooottttoooo((((3333TTTTkkkk))))                                                          pppphhhhoooottttoooo((((3333TTTTkkkk))))
  401.  
  402.  
  403.  
  404. KEYWORDS
  405.      photo, image, color
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.